package com.shinewind.info.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shinewind.info.mapper.IUserRoleMapper;
import com.shinewind.info.service.IUserRoleService;
import com.shinewind.pojo.entity.UserRole;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

@Service
@Transactional
@DubboService
public class UserRoleServiceImpl extends ServiceImpl<IUserRoleMapper, UserRole> implements IUserRoleService {
    @Override
    public List<String> getUserRoleByuId(String uId) {
        List<UserRole> UserRoles = this.lambdaQuery().eq(UserRole::getUId,uId).list();
        List<String> rolesList = UserRoles.stream().map(role -> {
            return role.getRole();
        }).collect(Collectors.toList());
        return rolesList;
    }
}
